<?php

/* 商品价格区间 volumeprice */
//bansen 2014.5.20
class VolumepriceModel extends BaseModel
{
    var $table  = 'volume_price';
    var $prikey = 'volume_id';
    var $alias  = 'gs';
    var $_name  = 'volumeprice';
    
    var $_relation  = array(
        // 一个商品属性只能属于一个商品
        'belongs_to_goods' => array(
            'model'         => 'goods',
            'type'          => BELONGS_TO,
            'foreign_key'   => 'goods_id',
            'reverse'       => 'has_volumeprice',
        ),
    );
	
	//根据goods_id获取gattr_id最小和最大的信息
	//goods_id:商品id
	function get_infos($goods_id)
	{
		if($goods_id>0)
		{
			$sql="select * from ".$this->table." where goods_id=".$goods_id." order by volume_number asc";
			$row = $this->db->getAll($sql);
			return $row;
		}
	}
	function delete($goods_id)
	{
		if($goods_id>0)
		{
			$sql="delete from ".$this->table." where goods_id=".$goods_id;
			$row = $this->db->query($sql);
			return $row;
		}
	}
	
}

?>